﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using TrieUtils;
using System.Linq;

namespace TrieUtilsTests
{
    [TestClass]
    public class TrieCollectionTest
    {
        [TestMethod]
        public void TestConstructor0()
        {
            new TrieCollection<string>();
        }

        [TestMethod]
        public void TestAdd()
        {
            var trie = new TrieCollection<string>();

            trie.Add("Hallo World");
        }
        
        [TestMethod]
        public void TestAddRange()
        {
            string[] lines = new string[] {
                "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
                "Nulla sodales tortor in ligula eleifend vel pulvinar neque suscipit.",
                "Suspendisse auctor libero quis eros rhoncus et eleifend libero eleifend.",
                "Curabitur et augue ac massa dapibus condimentum.",
                "Nunc vitae tortor vitae purus elementum dictum.",
                "Mauris porta accumsan eros, vitae luctus enim adipiscing id.",
                "Nunc blandit egestas tellus, vitae ornare est malesuada ut.",
                "Integer vel nibh non magna vulputate mollis.",
                "Curabitur aliquam tellus sit amet velit consectetur pellentesque ut quis quam.",
                "Praesent blandit eros id mi consectetur sed malesuada lectus sagittis."
            };

            var trie = new TrieCollection<string>();

            trie.AddRange(lines);
        }

        [TestMethod]
        public void TestFind1()
        {
            var trie = new TrieCollection<string>();

            trie.Add("Hallo World");

            var items = trie.FindItems("wor");

            Assert.AreNotEqual(null, items);
            Assert.AreEqual(1, items.Count());

            var firstItem = items.First();

            Assert.AreEqual("Hallo World", firstItem);
        }
    }
}